
PROJECT( TagFolderUnitTest)

FIND_LIBRARY( lib_gtest
    NAMES gtest
    PATHS "${tagfolder_base_dir}/depends/lib/${cpp_compiler}${machine_arch}"
    )
IF( ${lib_gtest} STREQUAL "lib_gtest-NOTFOUND")
    MESSAGE("gtest library not found, trying to build anyway...")
ENDIF( ${lib_gtest} STREQUAL "lib_gtest-NOTFOUND")

IF( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
    LINK_DIRECTORIES( 
        "${tagfolder_base_dir}/build/src/common"
        "/usr/lib")
    INCLUDE_DIRECTORIES( BEFORE
        "/usr/include"
        "${tagfolder_base_dir}/src/common/include/"
        "${CMAKE_CURRENT_SOURCE_DIR}")
ELSE( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
    LINK_DIRECTORIES( 
        "${tagfolder_base_dir}/build/src/common"
        "${tagfolder_base_dir}/depends/lib/${cpp_compiler}${machine_arch}")
    INCLUDE_DIRECTORIES( BEFORE
        "${tagfolder_base_dir}/depends/include/"
        "${tagfolder_base_dir}/src/common/include/"
        "${CMAKE_CURRENT_SOURCE_DIR}")
ENDIF( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)


# Macroes to define a tagfolder unit test under google unitest framework
MACRO( TAGFOLDER_UTEST TEST_TARGET TEST_SOURCE)
    ADD_EXECUTABLE( ${TEST_TARGET} ${ARGV})
    IF( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
        TARGET_LINK_LIBRARIES( ${TEST_TARGET} tagfolder gtest )
    ELSE( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
        TARGET_LINK_LIBRARIES( ${TEST_TARGET} tagfolder gtest gtest_main )
    ENDIF( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC )
    #${libgtest_path} ${libgtest_main_path} pthread)
ENDMACRO( TAGFOLDER_UTEST)

# This command runs perfectly on Ubuntu 10.10, 
# But the following cmake code won't work, don't know why, shit!
TAGFOLDER_UTEST( StringHasherTest StringHasherTest.cpp)


